﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Caching;


namespace ASBCC.WebCache
{
    public class CustomDependencyWebCache : WebCacheBase
    {
        private CacheDependency _dependencies;
        private DateTime _absoluteExpiration;
        private TimeSpan _slidingExpiration;
        CacheItemPriority _priority;
        private CacheItemRemovedCallback _onRemoveCallback;

        public override void Add(string key, object value)
        {
            if (!this.CheckParameters(key, value)) return;
            HttpRuntime.Cache.Insert(
                key,
                value,
                this._dependencies,
                this._absoluteExpiration,
                this._slidingExpiration,
                this._priority,
                this._onRemoveCallback);
        }

        public CustomDependencyWebCache(CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback)
        {
            this._dependencies = dependencies;
            this._absoluteExpiration = absoluteExpiration;
            this._slidingExpiration = slidingExpiration;
            this._priority = priority;
            this._onRemoveCallback = onRemoveCallback;
        }
    }
}
